﻿using ProjScan.ScanGUI;
using ProjScan.Tools;
using UnityEditor;

namespace ProjScan
{
    [InitializeOnLoad]
    public class Launcher
    {
        public const string MenuPath = "Assets/WzhEditor/Proj Scan/";
        static Launcher()
        {
            ApiCompatibilityUtils.Instance.Setup(ApiCompatibilityImp.Instance);
        }
        
        [MenuItem(MenuPath + "Run All Forcedly", false, 1)]
        private static void RunAll()
        {
            ScanMain.RunAll();
        }
        [MenuItem(MenuPath + "Run Seleted Modules", false, 2)]
        private static void Run_Selected_Modules()
        {
           ScanMain.Run_Selected_Modules();
        }

        [MenuItem(MenuPath + "Run Basic Assets Check", false, 3)]
        private static void Run_Basic_Assets_Check()
        {
            ScanMain.Run_Basic_Assets_Check();
        }
        
        [MenuItem(MenuPath + "Run Scenes Check", false, 4)]
        private static void Run_Scenes_Check()
        {
            ScanMain.Run_Scenes_Check();
        }

        [MenuItem(MenuPath + "Run Global Settings Check", false, 5)]
        private static void Run_Global_Settings_Check()
        {
            ScanMain.Run_Global_Settings_Check();
        }

        [MenuItem(MenuPath + "Run C# Scripts Check", false, 6)]
        private static void Run_CS_Check()
        {
            ScanMain.Run_CS_Check();
        }

        [MenuItem(MenuPath + "Run Custom Rules", false, 8)]
        private static void Run_Custom_Rules_Check()
        {
            ScanMain.Run_Custom_Rules_Check();
        }


        [MenuItem(MenuPath + "Run Effects Play Check", false, 9)]
        private static void Run_Effects_Play_Check()
        {
            ScanMain.Run_Effects_Play_Check();
        }


        [MenuItem(MenuPath + "Run Shader Analysis", false, 10)]
        private static void Run_Shader_Analysis()
        {
            ScanMain.Run_Shader_Analysis();
        }

        [MenuItem(MenuPath + "Run Art Assets Check", false, 11)]
        private static void Run_Art_Assets_Check()
        {
            ScanMain.Run_Art_Assets_Check();
        }
        
        
        [MenuItem(MenuPath + "Settings", false, 100)]
        private static void OpenScanSettingWindow() 
        {
            ScanSettingWindow.OpenScanSettingWindow();
        }

        [MenuItem(MenuPath + "About", false, 101)]
        public static void ShowAboutDialog()
        {
            if (EditorUtility.DisplayDialogComplex("Proj Scan", "Version: " + Singleton<ScanInfo>.Instance.version, "查看文档", "Cancel", "") == 0)
            {
                System.Diagnostics.Process.Start(Setting.HelpUrl + "/docx/SAeAda11zoNmuoxhS6ncMzVOnke");
            }
        }
    }
    
    static class FixLauncher
    {
        const string MenuPath = Launcher.MenuPath + "Fix Resource/";
        [MenuItem(MenuPath + "Fix All", false, 21)]
        private static void FixAll()
        {
            FixerMain.FixAll();
        }

        [MenuItem(MenuPath + "Fix Selected Modules", false, 21)]
        private static void FixSelectedModule()
        {
            FixerMain.FixSelectedModules();
        }
        [MenuItem(MenuPath + "Fix Global Setting", false, 22)]
        private static void FixGlobalSettings()
        {
            FixerMain.FixGlobalSettings();
        }

        [MenuItem(MenuPath + "Fix Basic Assets", false, 23)]
        private static void FixBasicAssets()
        {
            FixerMain.FixBasicAssets();
        }

        [MenuItem(MenuPath + "Fix Scenes", false, 24)]
        private static void FixScene()
        {
            FixerMain.FixScenes();
        }
    }
}
